<script setup lang="ts">
import {FilesCard} from "vue-element-plus-x";

const props = defineProps({
  files:{
    type:Object as PropType<any[]>,
    required:true
  }
});
const clickCard=(f:any)=>{
  if (f.url){
    window.open(f.url,'_blank');
  }
}
</script>

<template>
  <div class="file-list">
    <el-collapse>
      <el-collapse-item title="相关文件" name="file">
        <el-scrollbar height="200px">
          <div style="display: flex;flex-direction: column;gap: 5px;">
            <FilesCard v-for="(file,index) in files" :key="index" :name="file.url" :url="file.url" @click="clickCard(file)">
              <template #description>
                <div class="chat-text-overflow">
                  {{file.query}}
                </div>
              </template>
            </FilesCard>
          </div>
        </el-scrollbar>
      </el-collapse-item>
    </el-collapse>
  </div>
</template>

<style scoped lang="scss">
.chat-text-overflow {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
</style>
